package com.connector.base.exception;

import com.corundumstudio.socketio.SocketIOClient;
import com.corundumstudio.socketio.listener.ExceptionListenerAdapter;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;

import java.util.List;

public class CutExceptionListener extends ExceptionListenerAdapter
{
    public boolean exceptionCaught(final ChannelHandlerContext ctx, final Throwable e) {
        final Channel channel = ctx.channel();
        if (channel != null) {
            channel.close();
            ctx.close();
        }
        return true;
    }

    public void onConnectException(final Exception e, final SocketIOClient client) {
        System.out.println("onConnectException异常");
    }

    public void onEventException(final Exception e, final List<Object> data, final SocketIOClient client) {
        System.out.println("onEventException异常");
    }

    public void onDisconnectException(final Exception e, final SocketIOClient client) {
        System.out.println("onDisconnectException异常");
    }
}
